/*
 * Link.java
 *
 * Created on July 18, 2007, 11:15 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package org.atomojo.app.client;

import java.net.URI;
import org.restlet.data.MediaType;

/**
 *
 * @author alex
 */
public class Link
{
   Identity identity;
   String rel;
   MediaType type;
   URI link;
   
   /** Creates a new instance of Link */
   public Link(String rel,MediaType type, URI link)
   {
      this.rel = rel;
      this.type = type;
      this.link = link;
      this.identity = null;
   }

   /** Creates a new instance of Link */
   public Link(String rel, URI link)
   {
      this.rel = rel;
      this.type = null;
      this.link = link;
      this.identity = null;
   }
   public String getRelation()
   {
      return rel;
   }

   public MediaType getType()
   {
      return type;
   }

   public URI getLink()
   {
      return link;
   }
   
   public String getUsername() {
      return identity!=null ? identity.getName() : null;
   }
   
   public String getPassword() {
      return identity!=null ? identity.getPassword() : null;
   }
   
   public void setIdentity(String username,String password)
   {
      this.identity = new Identity(username,password);
   }
   
   public void setIdentity(Identity identity)
   {
      this.identity = identity;
   }
   
   public Identity getIdentity() {
      return identity;
   }
   
}
